bitkeeper revision 1.1159.76.4 (41486b81LlL7eGHBxdKlHNQ3D64MYA)
authormwilli2@equilibrium.research <mwilli2@equilibrium.research>
Wed, 15 Sep 2004 16:19:13 +0000 (16:19 +0000)
committermwilli2@equilibrium.research <mwilli2@equilibrium.research>
Wed, 15 Sep 2004 16:19:13 +0000 (16:19 +0000)
Restore xendomains script.

.rootkeys
tools/examples/init.d/xendomains [new file with mode: 0755]

index 1299c323baabeba5d179d355b1e099e58a40ecf7..8725479d091f0adf78ab72f9dae8999f53ba0e63 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile
 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
 405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend
+40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains
 40ee75a9xFz6S05sDKu-JCLqyVTkDA tools/examples/network
 40ee75a967sxgcRY4Q7zXoVUaJ4flA tools/examples/vif-bridge
 40ee75a93cqxHp6MiYXxxwR5j2_8QQ tools/examples/xend-config.sxp
diff --git a/tools/examples/init.d/xendomains b/tools/examples/init.d/xendomains
new file mode 100755 (executable)
index 0000000..41524e6
--- /dev/null
@@ -0,0 +1,146 @@
+#!/bin/sh
+#
+# /etc/init.d/xendomains
+# Start / stop domains automatically when domain 0 boots / shuts down.
+#
+# chkconfig: 345 99 00
+# description: Start / stop Xen domains.
+#
+# This script offers fairly basic functionality.  It should work on Redhat
+# but also on LSB-compliant SuSE releases and on Debian with the LSB package
+# installed.  (LSB is the Linux Standard Base)
+#
+# Based on the example in the "Designing High Quality Integrated Linux
+# Applications HOWTO" by Avi Alkalay
+# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
+#
+
+RETVAL=0
+
+INITD=/etc/init.d/
+
+AUTODIR=/etc/xen/auto
+LOCKFILE=/var/lock/subsys/xendomains
+
+if [ -e /lib/lsb ]; then
+    # assume an LSB-compliant distro (Debian with LSB package,
+    # recent-enough SuSE, others...)
+
+    . /lib/lsb/init-functions # source LSB standard functions
+
+    on_fn_exit()
+    {
+       if [ $RETVAL -eq 0 ]; then
+           log_success_msg
+       else
+           log_failure_msg
+       fi
+    }
+else
+    # assume a Redhat-like distro
+    . $INITD/functions # source Redhat functions
+
+    on_fn_exit()
+    {
+       if [ $RETVAL -eq 0 ]; then
+           success
+       else
+           failure
+       fi
+       
+       echo
+    }
+fi
+
+
+
+start() {
+    if [ -f $LOCKFILE ]; then return; fi
+
+    echo -n $"Starting auto Xen domains:"
+
+    # We expect config scripts for auto starting domains to be in
+    # AUTODIR - they could just be symlinks to files elsewhere
+    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
+       touch $LOCKFILE
+       
+       # Create all domains with config files in AUTODIR.
+       for dom in  $AUTODIR/*; do
+           xm create --quiet --defaults $dom
+           if [ $? -ne 0 ]; then
+               RETVAL=$?
+           fi
+       done
+
+    fi
+
+    on_fn_exit
+}
+
+stop()
+{
+    # NB. this shuts down ALL Xen domains (politely), not just the ones in
+    # AUTODIR/*
+    # This is because it's easier to do ;-) but arguably if this script is run
+    # on system shutdown then it's also the right thing to do.
+    
+    echo -n $"Shutting down all Xen domains:"
+
+    xm shutdown --all --wait --norestart
+
+    RETVAL=$?
+
+    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
+
+    on_fn_exit
+}
+
+# This does NOT necessarily restart all running domains: instead it
+# stops all running domains and then boots all the domains specified in
+# AUTODIR.  If other domains have been started manually then they will
+# not get restarted.
+# Commented out to avoid confusion!
+#
+#restart()
+#{
+#    stop
+#    start
+#}
+
+# same as restart for now - commented out to avoid confusion
+#reload()
+#{
+#    restart
+#}
+
+
+case "$1" in
+    start)
+       start
+       ;;
+
+    stop)
+       stop
+       ;;
+
+# The following are commented out to disable them by default to avoid confusion
+# - see the notes above
+#
+#    restart)
+#      restart
+#      ;;
+#
+#    reload)
+#      reload
+#      ;;
+
+    status)
+       xm list
+       ;;
+
+    *)
+       echo $"Usage: $0 {start|stop|status}"
+       ;;
+esac
+
+exit $RETVAL